<template>
    <rx-dialog @handOk="handOk" @cancel="cancel">
        <rx-layout class="form-header">
            <div slot="header">
                <a-form layout="inline" >
                  <a-row :gutter="24">
                    <a-col :span="8">
                      <a-form-item :label="$ti18('rxForm.name','名称')">
                        <a-input :placeholder="$ti18('rxForm.name','名称','','input')"
                                 v-model="queryParam.Q_NAME__S_LK"/>
                      </a-form-item>
                    </a-col>

                    <a-col :span="8">
                      <a-form-item :label="$ti18('rxForm.rxAlias', '别名')">
                        <a-input :placeholder="$ti18('rxForm.rxAlias', '别名','','input')"
                                 v-model="queryParam.Q_KEY__S_LK"/>
                      </a-form-item>
                    </a-col>

                    <a-col :span="8">
                        <span class="table-page-search-submitButtons" style="white-space: nowrap;">
                          <a-button type="primary" @click="$refs.table.loadData()"
                                    icon="search">{{ $ti18('rxList.searchBtn', '查询') }}</a-button>
                          <a-button style="margin-left: 4px"
                                    @click="resetSearch">{{ $ti18('rxList.resetBtn', '重置') }}</a-button>
                        </span>
                    </a-col>
                  </a-row>
                </a-form>
            </div>
            <div slot="center">
                <rx-grid
                    ref="table"
                    bordered
                    :allowRowSelect="true"
                    :multiSelect="multiSelect"
                    :columns="columns"
                    :defaultPageSize="10"
                    url="/api-form/form/core/formRegLib/query"
                    :queryParam="queryParam"
                    data-field="result.data"
                    :pageSizeOptions="['10','30','40']"
                    id-field="regId"
                    type="radio"
                    @selectChange="onSelectChange"
                    selectedRowKeys="selectedRowKeys"
                >
                </rx-grid>

            </div>
        </rx-layout>
    </rx-dialog>
</template>

<script>
import FormRegLibApi from "@/api/form/core/formRegLib";
import {BaseList, RxLayout, Util} from "@lowcode/jpaas-common-lib"

export default {
    name: 'FormRegLibDialog',
    mixins: [BaseList],
    components: {
        RxLayout
    },
    props: {
        layerid: {
            type: String,
            default: ""
        },
        destroy: {
            type: Function
        },
        multiSelect: {
            type: Boolean,
            default: true
        },
    },
    data() {
        return {
            columns: [
                {
                    title: '#',
                    scopedSlots: {customRender: 'serial'},
                    dataIndex: 'serial',
                    type: 'indexColumn',
                    width: '5%'
                },
                {title: this.$ti18('rxForm.name', '名称'), dataIndex: 'name'},
                {title: this.$ti18('rxForm.rxAlias', '别名'), dataIndex: 'key'}
            ]
        }

    },
    created() {
        this.queryParam['isShare'] = "YES";
        this.needFilterAppId();
    },
    methods: {
        getListByParams(parameter) {
            return FormRegLibApi.query(parameter)
        },
        getData() {
            if (this.multiSelect) {
                return this.selectedRows;
            }
            return this.selectedRows[0];
        },
        cancel() {
            Util.closeWindow(this, "cancel");
        },
        /**
         * 重置数据。
         */
        resetSearch() {
            this.queryParam = {
                isShare:"YES"
            };
            let appId = this.curApp.appId;
            if (this.hasAppId && appId) {
                this.queryParam.Q_APP_ID__S_EQ = appId;
            }
            this.$nextTick(() => {
                this.$refs[this.table].loadData();
            })
        },
        handOk(e) {
            var rows = this.selectedRows;
            if (rows.length == 0) {
                e.loading = false;
                this.$message.warning(this.$ti18('rxMsa.masWarn.selectOneRecord', '请选择一行记录!'));
                return;
            }
            Util.closeWindow(this, "ok");
        }
    }
}
</script>
<style scoped>
.form-header>>>.modeleBox{
  border-bottom:none;
}
</style>

